home *** CD-ROM | disk | FTP | other *** search
- /*
- ** PGP5GUI - A GUI using Magic User Interface v3.8
- **
- ** Copyright 23-JUNE-1998 by Stefan Zakarias, All Rights Reserved.
- **
- ** This source code is released as FREEWARE - Use it for whatever you like,
- ** as long as NO financial reward is gained by you for such usage.
- **
- ** If you use any parts of the this source code for anything, give ME credit
- ** wherever credit is due, please ;-)
- */
-
- /*
- ** Functions to handle the interface between PGPV and the GUI
- */
-
- /* Library stuff */
- #include <libraries/mui.h>
- #include <dos/dostags.h>
-
- /* Prototypes */
- #ifdef __GNUC__
- #include <clib/muimaster_protos.h>
- #include <proto/alib.h>
- #endif
-
- #include <proto/muimaster.h>
- #include <proto/exec.h>
- #include <clib/alib_protos.h>
- #include <clib/alib_stdio_protos.h>
- #include <proto/dos.h>
-
- /* Ansi */
- #include <string.h>
-
- /* Include generated by GenCodeC */
- #include "PGP5GUI.h"
-
- extern char *pgp5_tmp, *pgp5_tmp_asc;
-
- extern char *dec_files, *dec_outtype;
- extern char *decclippath, *decclipfile, *decclipfilename;
- extern char *exec_buff;
-
- extern BOOL GetSaveASLFileName(struct ObjApp *app, char *hail, char *pathbuff, char *filebuff, char *tofile);
-
- extern void PGP5_Execute(UBYTE *command, struct ObjApp *app);
- extern LONG GetCycle(Object *obj);
-
- extern BOOL ReadClipToFile(char *tmp, struct ObjApp *app);
- extern BOOL WriteFileToClip(char *tmp, struct ObjApp *app);
-
- /*
- ** Do the Decryption
- ** pgpv [-fmqv] [-z | -zs] [-o <outfile>] file ...
- */
- void
- Do_Decryption(struct ObjApp *App)
- {
- char tofile[512];
-
- /* Title for the file requester */
- char title[] = "Save Decrypted Clip To (.txt) Text File...";
-
- char *decfilesbuff = "\0";
-
- /* Values for the Cycle gadgets on the Decryption page */
- LONG Dec_OUTTYPE;
-
- Dec_OUTTYPE = GetCycle(App->CY_Decrypt_OUTTYPE);
-
- *decclipfilename = '\0';
-
- switch (Dec_OUTTYPE)
- {
- case 5: /* Decrypt/Verify from clipboard to clipboard */
- if (ReadClipToFile(pgp5_tmp_asc, App))
- {
- decfilesbuff = pgp5_tmp_asc;
- }
-
- break;
-
- case 4: /* Decrypt from clip to pager */
- case 3: /* Decrypt from clip to file */
- if (ReadClipToFile(pgp5_tmp_asc, App))
- {
- decfilesbuff = pgp5_tmp_asc;
-
- if (Dec_OUTTYPE == 3)
- {
- /* Get name of file to save encrypted clip to... */
- if (GetSaveASLFileName(App, title, decclippath, decclipfile, tofile))
- {
- /* Build up the command line to send to DOS */
- sprintf(decclipfilename, " +force -o \"%s\"", tofile);
- }
- else
- {
- /* Force exit */
- decfilesbuff = "\0";
- }
- }
- }
-
- break;
-
- case 2: /* Decrypt/Verify from file to clipboard */
- get(App->STR_PA_Decrypt_TOFILE,MUIA_String_Contents,&decfilesbuff);
-
- /* If we have a file name, then do decrypt/verify */
- if (*decfilesbuff)
- {
- if (WriteFileToClip(decfilesbuff, App))
- {
- if (ReadClipToFile(pgp5_tmp_asc, App))
- {
- decfilesbuff = pgp5_tmp_asc;
- }
- else
- {
- /* Force exit */
- decfilesbuff = "\0";
- }
- }
- else
- {
- /* Force exit */
- decfilesbuff = "\0";
- }
- }
-
- break;
-
- default: /* Decrypt/Verify from file to default (file) or internal pager */
- get(App->STR_PA_Decrypt_TOFILE,MUIA_String_Contents,&decfilesbuff);
- break;
- }
-
- if (*decfilesbuff)
- {
- strcpy(dec_files, decfilesbuff);
-
- if (Dec_OUTTYPE == 1 || Dec_OUTTYPE == 4)
- strcpy(dec_outtype, "-m");
- else
- *dec_outtype = '\0';
-
- sprintf(exec_buff, "PGPV %s %s \"%s\"", dec_outtype, decclipfilename, dec_files);
-
- /* Send the command to DOS */
- PGP5_Execute(exec_buff, App);
-
- if (Dec_OUTTYPE >= 2)
- {
- /* Clipboard mode... Send the decrypted file back to the clipboard */
- if (Dec_OUTTYPE == 2 || Dec_OUTTYPE == 5)
- {
- WriteFileToClip(pgp5_tmp, App);
- }
-
- /* Delete the temporary files (T:pgp5.tmp and T:pgp5.tmp.asc) */
- DeleteFile(pgp5_tmp);
- DeleteFile(pgp5_tmp_asc);
- }
- }
- }
-